package com.cskaoyan.service;

/**
 * @author dww
 */

import com.cskaoyan.bean.user.Feedback;
import com.cskaoyan.bean.user.FeedbackExample;
import com.cskaoyan.mapper.FeedbackMapper;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FeedBackServiceImpl implements FeedBackService{

    @Autowired
    private FeedbackMapper feedbackMapper;

    public List<Feedback> getFeedBackList(Integer page, Integer limit, String sort, String order, String username, Integer id) {
        PageHelper.startPage(page,limit,sort +" " + order);
        FeedbackExample example = new FeedbackExample();
        FeedbackExample.Criteria criteria = example.createCriteria();
//        if(StringUtil.isNotEmpty(username)){ criteria.andUsernameLike("%"+username+"%"); }
        if(username != null)
            criteria.andUsernameLike("%"+username+"%");
        if(id != null)
            criteria.andIdEqualTo(id);
        return feedbackMapper.selectByExample(example);
    }
}
